<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>SPRING</title>
<script type="text/javascript">
function validar() {
	var nome = document.getElementById("nome");
	if (nome == null || nome.value == '') {
		alert("Nome obrigatorio!"); 
		return false;		
	} else {		
		 return true;
	}
}
</script>
</head>
<body>
	<form action="./PessoaServlet" method="get" onsubmit="return validar();">
		<table>
			<tr>
				<td>Nome:</td>
				<td><input id="nome" name="nome" type="text"></td>
			</tr>
			<tr>
				<td colspan="2"><input name="acao" type="hidden" value="salvar" />
					<input type="submit" value="salvar" />
				</td>
			</tr>
		</table>
		<br />
		<table>
			<tr>
				<td>ID</td>
				<td>Nome</td>
				<td>Excluir</td>
			</tr>
			<c:forEach var="pessoa" items="${pessoas}">
				<tr>
					<td><c:out value="${pessoa.id}" /></td>
					<td><c:out value="${pessoa.nome}" /></td>
					<td><a href="./PessoaServlet?acao=excluir&id=${pessoa.id}">Excluir</a>
					</td>
				</tr>
			</c:forEach>
		</table>
	</form>
</body>
</html>